#include <iostream>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
const std::string gpipepath = "./fifo";
const int gdefaultfd = -1;
const int SIZE = 1024;
int read_flags = O_RDONLY;
int write_flags = O_WRONLY|O_APPEND;

int OpenFile(int flags)
{
    int fd = ::open(gpipepath.c_str(),flags);
    if (fd < 0)
    {
        std::cerr << "open error" << std::endl;
        return -1;
    }
    return fd;
}

bool CloseFile(int fd)
{
    if (fd >= 0)
    {
        ::close(fd);
        return true;
    }
    return false;
}